/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package registry;

import java.rmi.Remote;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import shared.PicRegistry;

/**
 *
 * @author Eric
 */
public class RegistryMain {
    public static void main(String[] args) {


           /* if (System.getSecurityManager() == null) {
                System.setSecurityManager(new SecurityManager());
            }
            * 
            */
            try {
                String name = "PicRegistry";
                PicRegistryController controller = new PicRegistryController();                
                controller.startRefresher();
                ConsoleOutput monitor = new ConsoleOutput();
                controller.addPicRegistryListener(monitor);
               
                PicRegistry stub =
                    (PicRegistry) UnicastRemoteObject.exportObject(controller, 0);
                Registry registry = LocateRegistry.getRegistry();
                registry.rebind(name, stub);
                System.out.println("RegistryController bound");
            } catch (Exception e) {
                System.err.println("RegistryController exception:");
                e.printStackTrace();
            }
        }
}
